#@layout() #define main()
<div class="xp-layout">
	<div id="departmennt_form" class="layui-form">
		<div class="layui-form-pane">
			<div class="layui-inline xp-input-container">
				<label class="layui-form-label">考场</label>
				<div class="layui-input-inline">
					<input class="layui-input" type="text" name="name" id="name">
				</div>
			</div>
			
			 <div class="layui-inline xp-input-container">
				<label class="layui-form-label">验收时间</label>
				<div class="layui-input-inline">
					<input type="text" id="beginTime" name="beginTime" lay-verify="" autocomplete="off" placeholder="请输入日期" class="layui-input">
				</div>
			</div> 
			
			<div class="layui-inline xp-input-container">
				<label class="layui-form-label">科目</label>
				<div class="layui-input-inline xp-select-container">
					<select id="subject" name="subject" lay-filter="changeType">
						<option value=' '>全部</option>
						<option value='科目一'>科目一</option>
						<option value='科目二'>科目二</option>
						<option value='科目三'>科目三</option>
					</select>
				</div>
			</div>
			
			<div class="layui-inline xp-input-container">
				<label class="layui-form-label">状态</label>
				<div class="layui-input-inline xp-select-container">
					<select id="status" name="status" lay-filter="changeType">
						<option value=' '>全部</option>
						<option value='3'>通过</option>
						<option value='4'>未通过</option>
						<option value='2'>正在验收</option>
						<option value='1'>未验收</option>
					</select>
				</div>
			</div>
			<div class="layui-inline xp-input-container">
				<button class="layui-btn" data-type="reload" id="findDeptList">
					<i class="layui-icon">&#xe615;</i> 查询
				</button>
			</div>
		</div>
	</div>
	<table id="department_table" lay-filter="table_tool"></table>
	
</div>

<script type="text/javascript">
	layui.use([ 'table', 'laydate','layer' ], function() {
		var table = layui.table,laydate = layui.laydate, form = layui.form;
		laydate.render({
			elem : '#beginTime' //指定元素
		});
		//第一个实例
		table.render({
			id : 'dept_table',
			elem : '#department_table',
			url : 'check/pagingData',
			even: true,
			limit:15,
			page : true,
			cols : [ [ {
				field : 'num',
				fixed : 'left',
				type : 'numbers'
			}, {
				field : 'name',
				title : '考场名称',
				width:400
			}, {
				field : 'subject',
				title : '科目',
				sort : true,
				width:100
			}, {
				field : 'shi',
				title : '地市',
				width:100
			}, {
				field : 'acceptanceDate',
				title : '验收时间'
			}, {
				field : 'ysry',
				title : '验收人员'
			},{
				field : 'status',
				title : '验收状态',
				templet : function(d) {
					if (d.status == '1') {
						return '<span style="color: blue;">等待验收</span>';
					} else if (d.status == '2') {
						if(d.checkStatus == 0){
							return '<span style="color: purple;">正在初验</span>';
						}
						if(d.checkStatus == 1){
							return '<span style="color: purple;">正在复验</span>';
						}
					} else if (d.status == '3') {
						if(d.checkStatus == 1){
							return '<span style="color: green;">初验通过</span>';
						}
						if(d.checkStatus == 2){
							return '<span style="color: green;">复验通过</span>';
						}
					}else if (d.status == '4') {
						if(d.checkStatus == 1){
							return '<span style="color: red;">初验未通过</span>';
						}
						if(d.checkStatus == 2){
							return '<span style="color: red;">复验未通过</span>';
						}
					}
				}
			}, {
				field : 'checkStatus',
				title : '验收结果',
				templet : function(d) {
					var kms ;
					if(d.subject=='科目一'){
						kms ='1';
					}else  if(d.subject=='科目二'){
						kms ='2';
					}else  if(d.subject=='科目三'){
						kms ='3';
					}
					if (d.checkStatus == '1') {
						return '<a class="layui-btn layui-btn-xs" lay-event="cy"  onclick="tzym('+d.ID+','+kms+',1)"      >初验</a> ';
					} else if (d.checkStatus == '2') {
						return '<a class="layui-btn layui-btn-xs" lay-event="cy"  onclick="tzym('+d.ID+','+kms+',1)"      >初验</a> <a class="layui-btn layui-btn-xs" lay-event="fy" onclick="tzym('+d.ID+','+kms+',2)"    >复验</a>';
					}else{
						return '';
					} 
				}
			}, {
				field : 'noticeNumber',
				title : '是否已下发通知书',
				templet : function(d) {
					if (d.noticeNumber=='1') {
						return '是';
					}else{
						return '否';
					}
				}
			} ] ]
		});

		//监听工具条
		var $ = layui.$, active = {
			reload : function() {

				//执行重载
				table.reload('dept_table', {
					page : {
						curr : 1
					},
					where : {
						name : $('#name').val(),
						subject : $('#subject').val(),
						status : $('#status').val() ,
						beginTime : $('#beginTime').val() 
					}
				});
			}
		};

		$('#departmennt_form .layui-btn').on('click', function() {
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});
	});

	function reloadList() {
		$('#findDeptList').click();
	}
	
	function tzym(eid,kms,check,yzm){
		/* if(check=='1'){
			 window.location.href='ysht/Rectificationys'+kms+'.html?id='+eid+'&checkStatus=1&subject='+kms;
		}else if(check=='2'){
			 window.location.href='ysht/Rectificationys'+kms+'.html?id='+eid+'&checkStatus=2&subject='+kms;
		}else{
			alert("验证码错误！无权限访问");
		}  */
		if(check=='1'){
			 window.location.href='ysht/Rectification'+kms+'.html?id='+eid+'&checkStatus=1&subject='+kms;
		}else if(check=='2'){
			 window.location.href='ysht/Rectification'+kms+'.html?id='+eid+'&checkStatus=2&subject='+kms;
		}else{
			alert("验证码错误！无权限访问");
		} 
	}
</script>

#end
